<?php
	
	if(!defined("IN_APP"))
	{
		exit;
	}
	
	if(!adminpermission('D','140001'))
	{
		echo '无权查看!';
		exit;
	}
	
	$method = getParam('m','get','list');
	
	$parm = requestArrayParm($_REQUEST);
	
	if($method == 'list')
	{
		$typearr['phone'] = '手机号';
		
		$fTitle = "短信管理";
		$sTitle = "短信列表";
		
		$search = array();
		
		if(!empty($parm['keyword']) && !empty($parm['type']))
		{
			$search[$parm['type']] = $parm['keyword'];
		}
		
		
		
		$page = $pages['page'] = getParam('page','request','1');
		
		$pages['rows'] = 20;
		
		$sorts['addtime'] = 'desc';
		
		$resData = _SqlTool::getList('sms', $search, $pages, $sorts, $between);
		
		//查询对应的数据
		
		foreach ($resData['list']  as $key => $value)
		{
			$list[] = $value;
		}
		
		$pageurl = SITE_URL.'admin.php?'.set_URL_Param(get_URL_Param());
	
		$pagetotal = $resData["pages"];
		
		include renderTemplate('sms/list');
	}
	
	if($method == 'send')
	{
		$pagetitle = '发送信息';
		
		$url = 'http://push3.realsms.cn:38812/api/v10/getBalance?usr=fumeng&pwd=qwer1234';
		$result = curl_send_post($url);
		
		$json = json_decode($result,true);
		
		if($json['code'] == 0)
		{
			$msginfo = '查询到余额信息,可发送'.$json['balance'].'条';
		}
		else
		{
			$msginfo = '暂未查询到余额信息';
		}
		
		include renderTemplate('sms/info');
	}
	